/*
 *  *
 * Copyright (C) 2007 lufang <lufang@gmail.com>
 *
 * Version 1.0 june 2007
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

#ifndef MODEM_USB_H
#define MODEM_USB_H

#include "sunxi_ril.h"

typedef enum _NetStandard
{
	NET_MODEM_SWITCH,
	NET_GSM,
	NET_CDMA,
}NetStandard;

struct _ModemUsb;
typedef struct _ModemUsb ModemUsb;

#define MODEM_USBSERIAL_UEVENT_FILE			"/sys/class/tty/%s%d/uevent"
#define MODEM_USBSERIAL_MAX_INDEX 		4	
#define MODEM_USBSERIAL_MAX_VALID_INDEX 20
#define MAX_PATH_LEN	255

/*struct _ModemUsb
{
	void 	(*suspend)(ModemUsb* thiz);
	void 	(*resume)(ModemUsb* thiz);
	void 	(*reset)(ModemUsb* thiz);
	int 	(*get_port_path)(ModemUsb* thiz, int index, char* path);
	int 	(*get_pid)(ModemUsb* thiz, int* vid, int* pid);
	void	(*destroy)(ModemUsb* thiz);
	int     (*exist)(ModemUsb* thiz);

	int		product_id;
	int		vendor_id;

	char* priv;
};*/

typedef struct _ModemPortConfig ModemPortConfig;

struct _ModemPortConfig
{
	int		at_port_index;
	int		data_port_index;
	NetStandard	network_type;
};

ModemUsb* 	modem_usb_create(int vendor_id, int product_id);
void 		modem_usb_suspend(ModemUsb* thiz);
void		modem_usb_resume(ModemUsb* thiz);
void		modem_usb_reset(ModemUsb* thiz);
int			modem_usb_get_port_path(ModemUsb* thiz, int index, char* path);
int     	modem_usb_get_pid(ModemUsb* thiz, int* vid, int* pid);
void		modem_usb_destroy(ModemUsb* thiz);
int 		modem_usb_get_port_config(ModemUsb* thiz, ModemPortConfig* config);
int			modem_usb_get_modem_info(ModemUsb* thiz, struct modem_info* info);
int         modem_usb_exist(ModemUsb* thiz);

ModemUsb*	modem_usb_factory_get_first_valid_usb();

int modem_getline(char** line, int* len, FILE* fp);
int modem_usb_read_pid(const char* uevent_file, int* vid, int* pid);
int modem_usb_get_valid_usb(int* vid, int* pid);
int modem_usb_init();
int modem_usb_uninit();
/* broncho yinlijun add */
char* modem_usb_get_product_name(ModemUsb* thiz);
void get_modem_info(unsigned int pid_vid_now, struct modem_info*** info_array, int* num);
int modem_usb_get_port_path_by_prefix(ModemUsb* thiz, const char* prefix, int index, char* path) ;


#endif

